<!DOCTYPE html>
<html lang="en">
<head th:include="certificateWeb/headFoot :: headerCss">
</head>
<link rel="stylesheet" href="/css/certificateWeb/workNews/workNews.css">
<style>
    .b18 {
        width: 300px;
        margin:0 auto 20px auto;
    }
    .download{
        border: 1px solid red;
        color: red;
        padding: 4px;
        margin-right: 20%;
        text-decoration:underline;
    }
    input{
        margin-right: 6px;
    }
    .doload{
        color: #e70012;
    }
    .certificateScribe{
        text-align: center;
        padding: 0 0 30px 0;
    }
    .pdf img{
        width: 30px;
    }
    .pdfList{
        padding-bottom: 12px;
    }
    .certificated,.no-data{
        display: none;
    }
    .no-data{
        text-align: center;
        padding-bottom: 20px;
    }
    .flex_a{
        padding-bottom: 30px;
    }
</style>
<body id="body">
<div th:include="certificateWeb/headFoot :: header"></div>
<main id="main">
    <section class="sec_1">
        <div class="div_1">
            <ul>
                <li><a href="/certificate/testingCentreQuery">考核站点查询</a></li>
                <li><a href="/certificate/testingCentreQueryPx">培训基地查询</a></li>
                <li class="this"><a href="/certificate/certificateQuery">1+x证书查询</a></li>
                <li><a href="/certificate/personalCertificateQuery">个人证书</a></li>
                <li><a href="/certificate/schoolCertificateQuery">学校证书</a></li>
                <li><a href="/certificate/expertQuery">专家查询</a></li>
            </ul>
        </div>

        <div class="div_2">
            <label class="label_title">1+x证书查询</label>
            <hr/>

            <div class="flex_a">
                <input type="text"  　id="name" placeholder="请输入姓名 " class="form-control" />
                <input type="text" name="numbers" 　id="idCard" placeholder="请输入身份证号 " class="form-control" />
                <!--                <input type="text" name="mobile" 　id="mobile" placeholder="报名手机号" class="form-control" />-->
                <!--                <input type="text" name="mobile" 　id="mobile" placeholder="报名手机号" class="form-control" />-->
                <input class="form-control but_2" type="button" id="search" value="查询" />
            </div>
<!--            <div class="div_2 div_01" id="list" style="margin-top: 20px">-->
<!--            </div>-->
            <div class="certificated">

                <div class="certificateBox">
                    <div class="certificateScribe">

                        <dl class="resultList">
                            <dd><span class="adjective">姓名：</span><span class="resultInfo myName"></span></dd>
                            <dd><span class="adjective">获证时间：</span><span class="resultInfo time"></span></dd>
                            <dd><span class="adjective">是否有效：</span><span class="resultInfo benefit">有效</span></dd>
                        </dl>

                        <div id="pdfBox">

                        </div>

                    </div>

                </div>

            </div>
            <div class="no-data">暂无数据</div>
        </div>
        <div style="clear: both"></div>
    </section>

</main>
<div th:include="certificateWeb/headFoot :: footer"></div>
<script>
    $(function () {
        $("#search").click(function () {
            var idCard = $("#idCard").val();
            var name = $("#name").val();
            var reg = /(^\d{15}$)|(^\d{18}$)|(^\d{17}(\d|X|x)$)/;
            if(!reg.test(idCard))
            {
                layer.msg("身份证号格式错误！");
                return;
            }
            if(name=='')
            {
                layer.msg("请输入姓名");
                return;
            }
            //查询简历·
            //  ajaxToken("/jzApi/user/selResume", "GET", {}, function (res) {
            // ajaxToken("/jzApi/user/selResume", "GET", {}, function (res) {

            // if (res.state == 0){
            var idCard = $("#idCard").val();
            var name = $("#name").val();
            // var mobile = $("#mobile").val();

            $.ajax({
                url: 'https://jzmy.jz1x.com/userService/jinZhiIndex/userServer/yyrselCertificate',
                data: {idCard: idCard,name:name },
                success: function (res) {
                    let list = res.data, str = '';
                    if (res.code == 0) {
                        if(list.length>0){
                            list.forEach(function (v) {
                                $(".myName").html(v.name);
                                $(".time").html(v.examYear);
                                $(".resultBook").html(v.certificatesType);
                                if( v.isEffective == 1 ){
                                    $(".benefit").html('有效')
                                }

                                str += `<div class="pdfList">
                                  <span class="pdf"><img src="/img/pdf.png"></span>
                                  <span class="name">${v.certificateType}</span>
                                  <a href="${v.url}" class="doload">下载</a>
                            </div>
                            `;
                            });
                            $("#pdfBox").html(str);
                            $('.certificated').show()
                            $('.no-data').hide()
                        }else{
                            $('.no-data').show()
                            $('.certificated').hide()
                        }
                        // var gradeName = '';
                        // if (res.data.grade == 0) {
                        //     gradeName = '高级'
                        // }else if(res.data.grade == 1){
                        //     gradeName = '中级'
                        // }else{
                        //     gradeName = res.data.grade;
                        // }
                        // var isEffective = '';
                        // if(res.data.isEffective == '0'||res.data.isEffective == 0){
                        //     isEffective = '有效'
                        // }else if(res.data.isEffective == 1){
                        //     isEffective = '无效'
                        // }else {
                        //     isEffective = '有效'
                        // }
                        // var list = res.data
                        // var content = ''
                        // list.forEach(function (item, index) {
                        //     content += '<image style="width:900px;height:636px;display: block;: 20px auto;text-align: center" src="' + item.cerImg + '"></image>' +
                        //         '<div class="span_1" style="text-align: right"><a download target="_blank" href="' + item.cerImg + '" class="download">下载图片</a></div>' +
                        //         // '<div class="span_1 b18"><span class="title_1">证书名称：</span><p class="title_2">' + res.data.certificateName + '</p></div>' +
                        //         //  '<div class="span_1 b18"><span class="title_1">证书等级：</span><p class="title_2">' + gradeName + '</p></div>' +
                        //         // '<div class="span_1 b18"><span class="title_1">证书名称：</span><p class="title_2">' + res.data.certificateName + '</p></div>' +
                        //         //  '<div class="span_1 b18"><span class="title_1">证书等级：</span><p class="title_2">' + gradeName + '</p></div>' +
                        //         '<div class="span_1 b18"><span class="title_1">证书编号：</span><p class="title_2">' + item.certificateNo + '</p></div>' +
                        //         // '<div class="span_1 b18"><span class="title_1">获证人姓名：</span><p class="title_2">' + res.data.name + '</p></div>' +
                        //         '<div class="span_1 b18"><span class="title_1">获证时间：</span><p class="title_2">' + item.addTime + '</p></div>' +
                        //         '<div class="span_1 b18"><span class="title_1">是否有效：</span><p class="title_2">' + isEffective + '</p></div>';
                        //     $("#list").html(content);
                        // })
                    }else{
                        layer.msg(res.msg)
                    }

                }
            })
            /*      }else {

                      layer.confirm("请先完善简历", {
                          btn: ['前去完善', '暂不完善']
                      }, function (index, layero) {
                          location.href = '/certificate/isResume'
                      }, function (index) {

                      })

                  }*/
            // });
            // })
        })
    })
</script>
</body>
</html>